import { useUserStore } from '@/store';

/**
 * @param {Array} value
 * @returns {Boolean}
 */
export function hasPermission(value: any): boolean {
  if (value) {
    const userStore = useUserStore();
    const permissions = userStore.getPermissions;
    if (permissions == null || permissions.length < 1) {
      return false
    }
    if (value instanceof Array) {
      return value.length > 0 && value.some(role => permissions.indexOf(role) > -1)
    }
    return permissions.indexOf(value) > -1
  } else {
    console.error('请设置操作权限标签值')
    return false
  }
}
